/*
 * Filehandler.cpp
 *
 * Created: 09-03-2013 13:14:41
 *  Author: Bootie
 */ 

#include "../Headers/Filehandler.h"

Filehandler::Filehandler()
{
}

Filehandler::~Filehandler()
{
}

bool Filehandler::WriteFile(char * _buffer, int _size)
{
	FRESULT res = f_write(&file, _buffer, _size, &FILE_BYTE_COUNT);
	if(res == FR_OK)
		return true;
	else
		return false;
}

bool Filehandler::ReadFile(char * _buffer, int _size)
{
	FRESULT res = f_read(&file, _buffer, _size, &FILE_BYTE_COUNT);
	if(res == FR_OK)
		return true;
	else
		return false;
}

bool Filehandler::OpenFile(char*filepath, BYTE flag)
{
	if(filepath == NULL)
	return false;
		
	FRESULT res = f_open(&file, filepath, flag);
	if(res == FR_OK)
		return true;
	else
		return false;
}

bool Filehandler::CloseFile()
{
	FRESULT res = f_close(&file);
	if(res == FR_OK)
		return true;
	else
		return false;
}